1
|
|
|
// Type definitions for wavefile-creator 1.0 |
2
|
|
|
// Project: https://github.com/rochars/wavefile-creator |
3
|
|
|
// Definitions by: Rafael da Silva Rocha <https://github.com/rochars> |
4
|
|
|
// Definitions: https://github.com/rochars/wavefile-creator |
5
|
|
|
|
6
|
|
|
export = wavefileCreator; |
7
|
|
|
|
8
|
|
|
declare module wavefileCreator { |
9
|
|
|
|
10
|
|
|
class WaveFileCreator { |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @param {?Uint8Array=} bytes A wave file buffer. |
14
|
|
|
* @throws {Error} If no 'RIFF' chunk is found. |
15
|
|
|
* @throws {Error} If no 'fmt ' chunk is found. |
16
|
|
|
* @throws {Error} If no 'data' chunk is found. |
17
|
|
|
*/ |
18
|
|
|
constructor(bytes?: Uint8Array); |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* The container identifier. |
22
|
|
|
* 'RIFF', 'RIFX' and 'RF64' are supported. |
23
|
|
|
* @type {string} |
24
|
|
|
*/ |
25
|
|
|
container: string; |
26
|
|
|
/** |
27
|
|
|
* @type {number} |
28
|
|
|
*/ |
29
|
|
|
chunkSize: number; |
30
|
|
|
/** |
31
|
|
|
* The format. |
32
|
|
|
* Always 'WAVE'. |
33
|
|
|
* @type {string} |
34
|
|
|
*/ |
35
|
|
|
format: string; |
36
|
|
|
/** |
37
|
|
|
* The data of the 'fmt' chunk. |
38
|
|
|
* @type {!Object<string, *>} |
39
|
|
|
*/ |
40
|
|
|
fmt: object; |
41
|
|
|
/** |
42
|
|
|
* The data of the 'fact' chunk. |
43
|
|
|
* @type {!Object<string, *>} |
44
|
|
|
*/ |
45
|
|
|
fact: object; |
46
|
|
|
/** |
47
|
|
|
* The data of the 'cue ' chunk. |
48
|
|
|
* @type {!Object<string, *>} |
49
|
|
|
*/ |
50
|
|
|
cue: object; |
51
|
|
|
/** |
52
|
|
|
* The data of the 'smpl' chunk. |
53
|
|
|
* @type {!Object<string, *>} |
54
|
|
|
*/ |
55
|
|
|
smpl: object; |
56
|
|
|
/** |
57
|
|
|
* The data of the 'bext' chunk. |
58
|
|
|
* @type {!Object<string, *>} |
59
|
|
|
*/ |
60
|
|
|
bext: object; |
61
|
|
|
/** |
62
|
|
|
* The data of the 'ds64' chunk. |
63
|
|
|
* Used only with RF64 files. |
64
|
|
|
* @type {!Object<string, *>} |
65
|
|
|
*/ |
66
|
|
|
ds64: object; |
67
|
|
|
/** |
68
|
|
|
* The data of the 'data' chunk. |
69
|
|
|
* @type {!Object<string, *>} |
70
|
|
|
*/ |
71
|
|
|
data: object; |
72
|
|
|
/** |
73
|
|
|
* The data of the 'LIST' chunks. |
74
|
|
|
* Each item in this list look like this: |
75
|
|
|
* { |
76
|
|
|
* chunkId: '', |
77
|
|
|
* chunkSize: 0, |
78
|
|
|
* format: '', |
79
|
|
|
* subChunks: [] |
80
|
|
|
* } |
81
|
|
|
* @type {!Array<!Object>} |
82
|
|
|
*/ |
83
|
|
|
LIST: object[]; |
84
|
|
|
/** |
85
|
|
|
* The data of the 'junk' chunk. |
86
|
|
|
* @type {!Object<string, *>} |
87
|
|
|
*/ |
88
|
|
|
junk: object; |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Set up the WaveFileReader object from a byte buffer. |
92
|
|
|
* @param {!Uint8Array} bytes The buffer. |
93
|
|
|
* @param {boolean=} samples True if the samples should be loaded. |
94
|
|
|
* @throws {Error} If container is not RIFF, RIFX or RF64. |
95
|
|
|
* @throws {Error} If no 'fmt ' chunk is found. |
96
|
|
|
* @throws {Error} If no 'data' chunk is found. |
97
|
|
|
*/ |
98
|
|
|
fromBuffer(bytes: Uint8Array, samples?:boolean): void; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Return a byte buffer representig the WaveFileCreator object as a .wav file. |
102
|
|
|
* The return value of this method can be written straight to disk. |
103
|
|
|
* @return {!Uint8Array} A wav file. |
104
|
|
|
*/ |
105
|
|
|
toBuffer(): Uint8Array; |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Set up the WaveFileCreator object based on the arguments passed. |
109
|
|
|
* Existing chunks are reset. |
110
|
|
|
* @param {number} numChannels The number of channels |
111
|
|
|
* (Integer numbers: 1 for mono, 2 stereo and so on). |
112
|
|
|
* @param {number} sampleRate The sample rate. |
113
|
|
|
* Integer numbers like 8000, 44100, 48000, 96000, 192000. |
114
|
|
|
* @param {string} bitDepthCode The audio bit depth code. |
115
|
|
|
* One of '4', '8', '8a', '8m', '16', '24', '32', '32f', '64' |
116
|
|
|
* or any value between '8' and '32' (like '12'). |
117
|
|
|
* @param {!Array<number>|!Array<!Array<number>>|!ArrayBufferView} samples |
118
|
|
|
* The samples. Must be in the correct range according to the bit depth. |
119
|
|
|
* @param {?Object} options Optional. Used to force the container |
120
|
|
|
* as RIFX with {'container': 'RIFX'} |
121
|
|
|
* @throws {Error} If any argument does not meet the criteria. |
122
|
|
|
*/ |
123
|
|
|
fromScratch( |
124
|
|
|
numChannels: number, |
125
|
|
|
sampleRate: number, |
126
|
|
|
bitDepthCode: string, |
127
|
|
|
samples: Array<number>|Array<Array<number>>|ArrayBufferView, |
128
|
|
|
options?: object): void; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|